const localize = require('ajv-i18n');

module.exports = function errorHandler(error, request, reply) {
  if (error.validation) {
    localize.zh(error.validation)
    const msg = error.validation[0].message
    reply.code(200).send({code: 400, msg: msg})
  } else {
    console.error(error)
    reply.code(200).send({code: 400, msg: '服务器错误'})
  }
}